//
//  YearView.m
//  仿系统日历
//
//  Created by 王猛 on 2022/11/16.
//

#import "YearView.h"
#import "UIColor+WM.h"

#define COLORHEX(hex) [UIColor colorWithHexString:hex]
@implementation YearView

- (instancetype)initWithFrame:(CGRect)frame withYearModel:(YearModel *)yearModel {
    if (self = [super initWithFrame:frame]) {
        self.yearModel = yearModel;
        [self setUI];
    }
    return self;
}

- (void)setUI {
    for (UIView *v in self.subviews) {
        [v removeFromSuperview];
    }
//
//    UIView *line1 = [[UIView alloc] initWithFrame:CGRectMake(0, self.frame.size.height - 0.8, self.frame.size.width, 0.8)];
//    line1.backgroundColor = [UIColor redColor];
//    [self addSubview:line1];
//
//    CGFloat BH = 40;
//    CGFloat BW = 60;
//    UILabel *lab1 = [[UILabel alloc] initWithFrame:CGRectMake(self.frame.size.width - BW, self.frame.size.height - 5 - BH, BW, BH)];
//    lab1.textColor = COLORHEX(@"937039");
//    lab1.textAlignment = NSTextAlignmentLeft;
//    lab1.font = [UIFont systemFontOfSize:10];
//    lab1.text = @"农历初一";
//    [self addSubview:lab1];
//    self.label3 = lab1;
//
//    UIView *line2 = [[UIView alloc] initWithFrame:CGRectMake(CGRectGetMinX(lab1.frame) - 15,CGRectGetMinY(lab1.frame)+(lab1.frame.size.height - 0.8)/2.0 , 10, 0.8)];
//    line2.backgroundColor = [UIColor yellowColor];
//    [self addSubview:line2];
    
//    UILabel *lab2 = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMinX(lab1.frame), CGRectGetMinY(lab1.frame) - BH, BW, BH)];
//    lab2.textColor = COLORHEX(@"0x888888");
//    lab2.textAlignment = NSTextAlignmentLeft;
//    lab2.font = [UIFont systemFontOfSize:10];
//    lab2.text = @"中国年";
//    [self addSubview:lab2];
//    self.label2 = lab2;
    
//    UIView *line3 = [[UIView alloc] initWithFrame:CGRectMake(CGRectGetMinX(lab2.frame) - 15,CGRectGetMinY(lab2.frame)+(lab2.frame.size.height - 0.8)/2.0 , 10, 0.8*2)];
//    line3.backgroundColor = [UIColor blueColor];
//    [self addSubview:line3];
    
    UILabel *lab3 = [[UILabel alloc] initWithFrame:CGRectMake(0, 20, 0, 0)];
    lab3.textAlignment = NSTextAlignmentLeft;
    lab3.font = [UIFont systemFontOfSize:32];
    lab3.textColor = COLORHEX(@"937039");
    lab3.text = [NSString stringWithFormat:@"%ld",(long)self.yearModel.year];
    [lab3 sizeToFit];
    [self addSubview:lab3];
    self.label1 = lab3;
    
//    NSDateComponents *components = [[NSCalendar currentCalendar] components:NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay | NSCalendarUnitWeekday fromDate:[NSDate date]];
//    if (self.yearModel.year == components.year) {
//        lab3.textColor = COLORHEX(@"0xea4e3d");
//    }else {
//        lab3.textColor = COLORHEX(@"0x000000");
//    }
}

@end
